//
//  BYClassificationItem.m
//  OCDemo
//
//  Created by zhumuzhi on 2022/2/13.
//

#import "BYClassificationItem.h"

@interface BYClassificationItem ()

@property (nonatomic, strong) UILabel *title;

@end


@implementation BYClassificationItem

#pragma mark - SetData

- (void)setData:(NSDictionary *)data {
    _data = data;
    self.title.text = SafeStr(data[@"title"]);
}

#pragma mark - Init

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if(self) {
        self.contentView.backgroundColor = [UIColor lightGrayColor];
        [self.contentView setViewCornerRadius:kAutoWithSize(8)];
        [self.contentView addSubview:self.title];
    }
    return self;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    
    [self.title mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.contentView);
    }];
    
    [super layoutSubviews];
}

- (UILabel *)title {
    if (!_title) {
        _title = [[UILabel alloc] init];
        _title.textAlignment = NSTextAlignmentCenter;
    }
    return _title;
}

@end
